<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
		<style>
			.service_goods {
				display: none;
			}
		</style>
	</head>
	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form" wid100 lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body" id="input_li">
							<div class="layui-form-item">
								<label class="layui-form-label">商品状态</label>
								<div class="layui-input-block on_off"></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商品类型</label>
								<div class="layui-input-block goods_type"></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">客户端</label>
								<div class="layui-input-block icon_type"></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">分期</label>
								<div class="layui-input-block fq_status"></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">是否推荐</label>
								<div class="layui-input-block ">
									<input type="radio" name="recommend" value="1" title="是">
									<div class="layui-unselect layui-form-radio layui-form-radioed"><i
											class="layui-anim layui-icon"></i>
										<div>是</div>
									</div><input type="radio" name="recommend" value="0" title="否" checked="checked">
									<div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
										<div>否</div>
									</div>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">能否加入购物车</label>
								<div class="layui-input-block ">
									<input type="radio" name="cart" value="1" title="是" checked="checked">
									<div class="layui-unselect layui-form-radio layui-form-radioed"><i
											class="layui-anim layui-icon"></i>
										<div>是</div>
									</div><input type="radio" name="cart" value="0" title="否">
									<div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
										<div>否</div>
									</div>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">商品名称</label>
								<div class="layui-input-block">
									<input type="text" name="skuname" placeholder="请输入商品名称" autocomplete="off"
										class="layui-input" lay-verify="required">
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label">商品简称</label>
									<div class="layui-input-block">
										<input type="text" name="title" placeholder="请输入商品简称" autocomplete="off"
											class="layui-input" lay-verify="required">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">最低购买数量</label>
								<div class="layui-input-block">
									<input type="text" name="low_quantity" placeholder="请输入最低购买数量" autocomplete="off"
										class="layui-input" lay-verify="required">
								</div>
							</div>
							<!--<div class="layui-form-item">
								<label class="layui-form-label">产品编号</label>
								<div class="layui-input-inline">
									<input type="text" name="spuid" placeholder="请输入产品编号" autocomplete="off" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux"><a href="Javascript:;" onclick="searchdata('spuid')">选择</a></div>
							</div> -->


							<div class="layui-form-item service_goods">
								<label class="layui-form-label">选择子商品:</label>

								<!--<div class="layui-input-block">
									<textarea type="text" name="sub_skuname" placeholder="请输入选择子商品" autocomplete="off" class="layui-textarea sub_skuname"></textarea>
									<input type="text" name="sub_skuid" placeholder="请输入选择子商品" autocomplete="off" class="layui-input sub_skuid" style="display: none;">
								</div>-->
								<div class="layui-input-block">
									<div class="layui-form">
										<table class="layui-table">
											<colgroup>
												<col width="150">
												<col width="150">
												<col width="150">
											</colgroup>
											<thead>
												<tr>
													<th>商品名称</th>
													<th>商品编号</th>
													<th>操作</th>
												</tr>
											</thead>
											<tbody class="tbody_tr" id="tbody_tr"></tbody>
										</table>
									</div>
								</div>
								<div class="layui-input-block">
									<div class="layui-form-mid layui-word-aux">
										<a href="Javascript:;" onclick="searchdata('sub_skuid')">选择</a>
									</div>
								</div>
							</div>

							<div class="layui-form-item service_goods">
								<div class="layui-inline">
									<label class="layui-form-label">开始服务时间</label>
									<div class="layui-input-inline">
										<input type="text" name="rangeStartTime" class="layui-input" id="rangeStartTime"
											placeholder=" HH:mm:ss">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">结束服务时间</label>
									<div class="layui-input-inline">
										<input type="text" name="rangeEndTime" class="layui-input" id="rangeEndTime"
											placeholder=" HH:mm:ss">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">服务时长(分钟)</label>
									<div class="layui-input-inline">
										<input type="text" name="intervalTime" class="layui-input" />
									</div>
								</div>
							</div>




							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">产品名称</label>
									<div class="layui-input-inline">
										<input type="text" name="spuname" placeholder="请输入产品名称" autocomplete="off"
											class="layui-input" lay-verify="">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">产品编号</label>
									<div class="layui-input-inline">
										<input type="text" name="spuid" placeholder="请输入产品编号" autocomplete="off"
											class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux"><a href="Javascript:;"
											onclick="searchdata('spuid')">选择</a></div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">直推佣金</label>
									<div class="layui-input-block">
										<input type="text" name="direct_fee" placeholder="请输入直推佣金" autocomplete="off"
											class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">间推佣金</label>
									<div class="layui-input-block">
										<input type="text" name="indirect_fee" placeholder="请输入间推佣金" autocomplete="off"
											class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">团队佣金</label>
									<div class="layui-input-block">
										<input type="text" name="team_fee" placeholder="请输入团队佣金" autocomplete="off"
											class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">合伙人佣金</label>
									<div class="layui-input-block">
										<input type="text" name="copartner_fee" placeholder="请输入合伙人佣金"
											autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item service_goods">
								<div class="layui-inline">
									<label class="layui-form-label">区域店铺佣金</label>
									<div class="layui-input-inline">
										<input type="text" name="area_fee" placeholder="请输入区域店铺佣金" autocomplete="off"
											class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">城市店铺佣金</label>
									<div class="layui-input-inline">
										<input type="text" name="city_fee" placeholder="请输入城市店铺佣金" autocomplete="off"
											class="layui-input">
									</div>
								</div>
							</div>

							<!--<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">品牌名称</label>
									<div class="layui-input-inline">
										<input type="text" name="brand_name" placeholder="请输入品牌名称" autocomplete="off" class="layui-input">
									</div> 
									<div class="layui-form-mid layui-word-aux"><a href="Javascript:;" onclick="searchdata('brand_id')">选择</a></div>
								</div>
								<div class="layui-inline" style="display: none;">
									<label class="layui-form-label">品牌编号</label>
									<div class="layui-input-inline">
										<input type="text" name="brand_id" placeholder="请输入品牌编号" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div> -->

							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label">规格名称</label>
									<div class="layui-input-block">
										<input type="text" name="specname" placeholder="请输入规格名称" autocomplete="off"
											class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label">规格参数</label>
									<div class="layui-input-block">
										<input type="text" name="specparam" placeholder="请输入规格参数" autocomplete="off"
											class="layui-input">
									</div>
								</div>
							</div>

							<!--<fieldset class="layui-elem-field layui-form-item" style="width: 90%;margin-left: 50px;display: none;" id="spec">
								  <legend>规格</legend>
								  <div class="layui-field-box">
								    
									<div class="layui-form-item">
										<div class="layui-inline">
											<label class="layui-form-label">规格名称</label>
											<div class="layui-input-inline">
												<input type="text" name="spec_k" placeholder="请输入规格名称" autocomplete="off" class="layui-input"  >
											</div>
										</div>
										<div class="layui-inline">
											<label class="layui-form-label">规格参数</label>
											<div class="layui-input-inline">
												<input type="text" name="spec_v" placeholder="请输入规格参数" autocomplete="off" class="layui-input" >
											</div>
										</div>
									
										
										<button type="button" class="layui-btn layui-btn-sm spec_add"><i class="layui-icon"></i></button>
									   <button type="button" class="layui-btn layui-btn-sm spec_del" style="display: none;"><i class="layui-icon"></i></button>
									</div>
								    
								  </div>
							</fieldset>-->
							<!--<div class="layui-inline">
											<label class="layui-form-label">价格</label>
											<div class="layui-input-inline">
												<input type="text" name="spec_price" placeholder="请输入价格" autocomplete="off" class="layui-input" >
											</div>
										</div>-->

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">计量单位</label>
									<div class="layui-input-inline">
										<input type="text" name="measure_unit" placeholder="请输入计量单位" autocomplete="off"
											class="layui-input">
									</div>
								</div>
								<!--<div class="layui-inline">
									<label class="layui-form-label">最低购买数量</label>
									<div class="layui-input-inline">
										<input type="text" name="low_quantity" placeholder="请输入最低购买数量" autocomplete="off" class="layui-input">
									</div>
								</div>-->
							</div>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">原价<span style="color:red">*</span></label>
									<div class="layui-input-inline">
										<input type="text" name="price" placeholder="请输入购买原价" lay-verify="number"
											autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">购买会员价<span style="color:red">*</span></label>
									<div class="layui-input-inline">
										<input type="text" name="price_member" placeholder="请输入购买会员价"
											lay-verify="number" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label">折扣<span style="color:red">*</span></label>
									<div class="layui-input-block">
										<input type="text" name="discount" placeholder="请输入折扣：0.99 代表99折"
											lay-verify="discount" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>


							<!--<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">抢购价</label>
									<div class="layui-input-inline">
										<input type="text" name="limit_price" placeholder="请输入抢购价" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">营销价</label>
									<div class="layui-input-inline">
										<input type="text" name="market_price" placeholder="请输入营销价" autocomplete="off" class="layui-input">
									</div>
								</div> 
								<div class="layui-inline">
									<label class="layui-form-label">优惠价</label>
									<div class="layui-input-inline">
										<input type="text" name="coupon_price" placeholder="请输入优惠价" autocomplete="off" class="layui-input">
									</div>
								</div> 
							</div>-->
							<div class="layui-form-item">
								<!--<div class="layui-inline">
									<label class="layui-form-label">积分百分比</label>
									<div class="layui-input-inline">
										<input type="text" name="score_scale"  placeholder="请输入积分抵扣百分比" autocomplete="off" class="layui-input">
									</div>
								</div>  -->
								<div class="layui-inline">
									<label class="layui-form-label">积分抵扣</label>
									<div class="layui-input-inline">
										<input type="text" name="score" lay-verify="number | required"
											placeholder="请输入积分抵扣" autocomplete="off" class="layui-input">

									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">专属等级</label>
									<div class="layui-input-inline">
										<select name="level" class="site_union">
										</select>
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">赠送等级</label>
									<div class="layui-input-inline">
										<select name="grade" class="site_union">
										</select>
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">赠送月份</label>
									<div class="layui-input-inline">
										<input type="text" name="grade_month" placeholder="请输入赠送月份" autocomplete="off"
											class="layui-input">
									</div>
								</div>
							</div>


							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">当前库存<span style="color:red">*</span></label>
									<div class="layui-input-inline">
										<input type="text" name="stock" placeholder="请输入当前库存" autocomplete="off"
											class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">当前销量<span style="color:red">*</span></label>
									<div class="layui-input-inline">
										<input type="text" name="sales" placeholder="请输入当前销量" autocomplete="off"
											class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">商品运费</label>
									<div class="layui-input-inline">
										<input type="text" name="price_waybill" placeholder="请输入商品运费" autocomplete="off"
											class="layui-input">

									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">发货说明</label>
								<div class="layui-input-block">
									<textarea placeholder="请输入发货说明" name="instructions"
										class="layui-textarea"></textarea>
								</div>
							</div>


							<div class="layui-form-item">
								<label class="layui-form-label">商品简介</label>
								<div class="layui-input-block">
									<textarea placeholder="请输入商品简介" name="intro" class="layui-textarea"></textarea>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">商品介绍</label>
								<div class="layui-input-block">
									<textarea class="layui-textarea layui-hide" name="content" lay-verify="content"
										id="demo_editor"></textarea>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">店铺信息</label>
								<div class="layui-input-block">
									<textarea placeholder="请输入店铺信息" name="support" class="layui-textarea"></textarea>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商品示例图</label>
								<div class="layui-input-block">
									<button type="button" class="layui-btn layui-btn-normal"
										onclick="choose(5)">上传图片</button>

									<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
										<ul class="show_img_ul" id="shili"></ul>
									</blockquote>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商品主图</label>
								<div class="layui-input-block">
									<button type="button" class="layui-btn layui-btn-normal"
										onclick="choose(1)">上传图片</button>

									<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
										<ul class="show_img_ul" id="zhutu"></ul>
									</blockquote>
									<textarea placeholder="请输入售后保障" name="support" class="layui-textarea"></textarea>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商品轮播图</label>
								<div class="layui-input-block">
									<button type="button" class="layui-btn layui-btn-normal"
										onclick="choose(2)">上传图片</button>

									<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
										<ul class="show_img_ul" id="lunbo"></ul>
									</blockquote>
								</div>
							</div>
							<div class="layui-form-item upvideo">
								<label class="layui-form-label">视频</label>
								<div class="layui-input-block">
									<button type="button" class="layui-btn layui-btn-normal upimgbtn"
										onclick="choose(3)">上传视频</button>
									<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
										预览视频：
										<div class="layui-upload-list upload_list" id="video_url">
											<ul class="show_img_ul" id="video"></ul>
										</div>
									</blockquote>

								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商品视频封面</label>
								<div class="layui-input-block">
									<button type="button" class="layui-btn layui-btn-normal"
										onclick="choose(4)">上传图片</button>
									<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
										<ul class="show_img_ul" id="video_cover"></ul>
									</blockquote>
								</div>
							</div>
						</div>
					</div>

					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>



		<script type="text/html" id="sub_skuid">
		{{# layui.each(d,function(index,o){ }}
			<tr>
				<td>{{o.skuid}}</td>
				<td>{{o.skuname}}</td>
				<td>
					<button type="button" class="layui-btn layui-btn-danger del_tr" index="{{index}}"><i
							class="layui-icon"></i></button>
				</td>
			</tr>
			{{# })}}
		</script>


		<script type="text/html" id="input_list">
		{{# layui.each(d,function(index,item){ }}
			<div class="layui-form-item">
				<label class="layui-form-label">{{item.name}}</label>

				{{# if(item.input_btn == 1){ }}
					{{# if(item.verify && item.verify == 1){ }}
						<div class="layui-input-block">
							<input type="text" name="{{item.id}}" placeholder="请输入{{item.name}}" autocomplete="off"
								class="layui-input" lay-verify="required">
							{{# if(item.id == 'spuid'){ }}
								<div class="layui-form-mid layui-word-aux"><a href="Javascript:;"
										onclick="searchdata('spuid')">选择</a></div>
								{{# } }}
						</div>
						{{# } else { }}
							<div class="layui-input-block">
								<input type="text" name="{{item.id}}" placeholder="请输入{{item.name}}" autocomplete="off"
									class="layui-input">
								{{# if(item.id == 'spuid'){ }}
									<div class="layui-form-mid layui-word-aux"><a href="Javascript:;"
											onclick="searchdata('spuid')">选择</a></div>
									{{# } }}
							</div>
							{{# } }}



								{{# } else if(item.input_btn == 2 || item.input_btn == 3) { }}

									<div class="layui-input-block {{item.id}}"></div>

									{{# } else if(item.input_btn == 4) { }}

										<div class="layui-input-block">
											<textarea placeholder="请输入{{item.name}}" name="{{item.id}}"
												class="layui-textarea"></textarea>
										</div>

										{{# } else if(item.input_btn == 5) { }}

											<div class="layui-input-block">
												<textarea class="layui-textarea layui-hide" name="{{item.id}}"
													lay-verify="{{item.id}}" id="demo_editor"></textarea>
											</div>

											{{# } else if(item.input_btn == 6) { }}

												<div class="layui-input-inline">
													<select name="{{item.id}}" class="site_union">
													</select>
												</div>

												{{# } else if(item.input_btn == 7) { }}

													<div class="layui-input-block">
														<button type="button" class="layui-btn layui-btn-normal"
															onclick="choose({{item.data}})">上传{{item.data == 3 ? '视频' : '图片'}}</button>

														<blockquote class="layui-elem-quote layui-quote-nm"
															style="margin-top: 10px;">
															<ul class="show_img_ul" id="{{item.id}}"></ul>
														</blockquote>
													</div>

													{{# } }}
			</div>
			{{# })}}
		</script>




		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../js/ace/ace.js"></script>
		<script src="../../../js/common.js"></script>
		<!--<script src="https://raw.githack.com/hnzzmsf/layui-formSelects/master/dist/formSelects-v4.min.js" type="text/javascript" charset="utf-8"></script>-->
		<script src="../../../layuiadmin/modules/formSelects-v4.js"></script>
		<script>
			var _data = {
				skuid: getParam('skuid'),
				client: '',
				spuid: ''
			}

			var request_data = []
			var goods_arr = []
			var str = '';

			function child(data, index) {
				$(" input[name=spuname]").val(data.spuname);
				$(" input[name=spuid]").val(data.spuid);
			}

			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				tinymce: '../tinymce/tinymce',
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'laydate', 'layedit', 'upload', 'tinymce', 'util'], function() {
				var $ = layui.$,
					admin = layui.admin,
					upload = layui.upload,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					util = layui.util,
					tinymce = layui.tinymce,
					form = layui.form;

				initmodule()

				var img_arr1 = [],
					img_arr2 = [],
					img_arr3 = [],
					img_arr4 = [];
				img_arr5 = [];

				//日期时间选择器
				laydate.render({
					elem: '#rangeStartTime',
					type: 'time'
				});
				laydate.render({
					elem: '#rangeEndTime',
					type: 'time'
				});

				var edit = tinymce.render({
					elem: "#demo_editor",
					height: 600
				});

				on_off_show('radio');
				fq_status_show('radio');
				// recommend_show('radio');
				// cart_show('radio');
				icon_type_show('checkbox')
				site_union_show("option")
				goods_type_show('radio')

				if (_data.skuid) {
					initdata();
					$("#spec").show()
				} else {
					$("#spec").hide()
				}

				init_service()

				function init_service() {
					var radio = $("input[name=type]")
					for (var i = 0; i < radio.length; i++) {
						// console.log(radio[i])
					}
				}

				form.on('radio(type)', function(data) {
					var level = data.value; //被点击的radio的value值        
					if (level.toString() == '1') {
						$(".service_goods").show();
					} else {
						$(".service_goods").hide();
					}
					console.log(data.elem); //得到radio原始DOM对象
					console.log(level);
					console.log(level.toString() == '1');
				})

				util.event('lay-event', {
					preveiw: function() {
						layer.open({
							type: 2,
							title: '预览',
							shadeClose: false,
							shade: 0.5,
							maxmin: true, //开启最大化最小化按钮
							area: ['60%', '80%'],
							content: 'pre_content.html',
							end: function() {},
							success: function(layero, index) {
								var body = layer.getChildFrame('body', index);
								body.find(".title").html($('input[name=title]').val());
								body.find(".showcontent").html(edit.getContent());
							}
						});
					},
				});

				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data);
					_data.goods_image_url = img_arr1.join(',');
					_data.goods_gallery_urls = img_arr2.join(',');
					_data.video_url = img_arr3.join(',');
					_data.video_cover = img_arr4.join(',');
					_data.examples_img_url = img_arr5.join(',');
					_data.content = edit.getContent();
					_data.client = '';

					for (item in data) {
						if (/^c/.test(item)) {
							if (item.substr(0, 6) == 'client') {
								_data.client += data[item] + ','
								console.log(item.substr(0, 6))
								console.log(item)
								console.log(data[item])
							}
						}
					}

					_data.client = (_data.client.substring(_data.client.length - 1) == ',') ? _data.client
						.substring(0, _data.client.length - 1) : _data.client;
					_data.sub_skuid = ''

					for (var i = 0; i < goods_arr.length; i++) {
						_data.sub_skuid += goods_arr[i].skuid;
						if (i != goods_arr[i].length - 1) {
							_data.sub_skuid += ",";
						}
					}
					console.log(data)

					// layer.confirm('确定要提交数据？', function() {
					// 	loading();
					// 	if(_data.type == 0){
					// 		_data.test_typ == '';
					// 	}
					// 	if (_data.skuid) {
					// 		submitdata(server.updategoods);
					// 		console.log(_data.examples_img_url);
					// 	} else {
					// 		submitdata(server.addgoods);
					// 	}
					// }, function() {
					// 	layer.msg('取消操作');
					// });
					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								closeloading();
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}

				window.searchdata = function(type) {
					switch (type) {
						case 'spuid':
							layer.open({
								type: 2,
								title: '选择产品',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['80%', '90%'],
								content: 'choose_spuid.html',
								end: function() {
									_data.spuid = $('input[name=spuid]').val()
									setTimeout(function() {
										if (_data.spuid) {
											productdetail(_data.spuid)
										}
									}, 300)
								},
								success: function() {

								}
							});
							break;
						case 'brand_id':
							layer.open({
								type: 2,
								title: '选择品牌',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['90%', '90%'],
								content: 'choose_brand.html',
								end: function() {
									_data.brand_id = $('input[name=brand_id]').val()
								},
								success: function() {}
							});
							break;
						case 'sub_skuid':
							layer.open({
								type: 2,
								title: '选择子商品',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['90%', '90%'],
								content: 'choose_sub_goods.html',
								success: function() {

								},
								end: function() {
									console.log(_data)
									var skuid = _data.id ? _data.id.split(",") : ''
									var skunames = _data.skunames ? _data.skunames.split(",") : ''
									for (var i = 0; i < skuid.length; i++) {
										goods_arr.push({
											skuid: skuid[i],
											skuname: skunames[i]
										})
									}
									show_goods_arr(goods_arr)
								}
							});
							break;
						default:
							break;
					}
				}

				function show_goods_arr(goods_arr) {
					var getTpl = sub_skuid.innerHTML,
						view = document.getElementById('tbody_tr');
					laytpl(getTpl).render(goods_arr, function(html) {
						view.innerHTML = html;
					});
				}
				window.choose = function(data) {
					layer.open({
						type: 2,
						title: '上传图片',
						shadeClose: false,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['700px', '400px'],
						content: 'up_report.html?type=' + data,
						end: function() {},
						success: function() {}
					});
				}

				window.getimg = function(data, type) {
					console.log(data);
					if (data) {
						switch (type) {
							case '1':
								createli(data, 'zhutu', type)
								break;
							case '2':
								createli(data, 'lunbo', type)
								break;
							case '3':
								createli(data, 'video_url', type)
								break;
							case '4':
								createli(data, 'video_cover', type)
								break;
							case '5':
								createli(data, 'shili', type)
								break;
							default:
								break;
						}
					}
				}

				window.delimg = function(i, type, _self) {
					var _type = String(type)
					var lock = false
					layer.confirm('确定要删除图片？', function(index) {
						if (!lock) {
							lock = true
							switch (_type) {
								case '1':
									img_arr1.splice(i, 1)
									break;
								case '2':
									img_arr2.splice(i, 1)
									break;
								case '3':
									img_arr3.splice(i, 1)
									break;
								case '4':
									img_arr4.splice(i, 1)
									break;
								case '5':
									img_arr5.splice(i, 1)
									break;
								default:
									break;
							}
							$(_self).parent().remove();
							layer.close(index)
						}

					}, function() {
						layer.msg('取消操作');
					});
				}

				function createli(data, dom, type) {
					var lihtml = '';
					switch (type) {
						case '1':
							if (data.indexOf(',') == -1) {
								img_arr1.push(data)
							} else {
								for (var i = 0; i < data.split(',').length; i++) {
									img_arr1.push(data.split(',')[i])
								}
							}

							for (var i = 0; i < img_arr1.length; i++) {
								lihtml += '<li class="show_img_li">' +
									'<img src=' + img_arr1[i] + ' >' +
									'<p onclick="delimg(' + i + ',1,this)">删除</p>' +
									'</li>'
							}
							break;
						case '2':
							if (data.indexOf(',') == -1) {
								img_arr2.push(data)
							} else {
								for (var i = 0; i < data.split(',').length; i++) {
									img_arr2.push(data.split(',')[i])
								}
							}
							for (var i = 0; i < img_arr2.length; i++) {
								lihtml += '<li class="show_img_li">' +
									'<img src=' + img_arr2[i] + ' >' +
									'<p onclick="delimg(' + i + ',2,this)">删除</p>' +
									'</li>'
							}
							break;
						case '3':
							if (data.indexOf(',') == -1) {
								img_arr3.push(data)
							} else {
								for (var i = 0; i < data.split(',').length; i++) {
									img_arr3.push(data.split(',')[i])
								}
							}
							for (var i = 0; i < img_arr3.length; i++) {
								lihtml += '<li class="show_img_li">' +
									'<video controls="controls" id="video{{index}}" width="320" height="240"><source src=' +
									img_arr3[i] + ' type="video/ogg" /><source src=' + img_arr3[i] +
									' video/mp4" /></video>' +
									'<p onclick="delimg(' + i + ',3,this)">删除</p>' +
									'</li>'
							}

							break;
						case '4':
							if (data.indexOf(',') == -1) {
								img_arr4.push(data)
							} else {
								for (var i = 0; i < data.split(',').length; i++) {
									img_arr4.push(data.split(',')[i])
								}
							}
							for (var i = 0; i < img_arr4.length; i++) {
								lihtml += '<li class="show_img_li">' +
									'<img src=' + img_arr4[i] + ' >' +
									'<p onclick="delimg(' + i + ',4,this)">删除</p>' +
									'</li>'
							}
							break;
						case '5':
							if (data.indexOf(',') == -1) {
								img_arr5.push(data)
							} else {
								for (var i = 0; i < data.split(',').length; i++) {
									img_arr5.push(data.split(',')[i])
								}
							}
							for (var i = 0; i < img_arr5.length; i++) {
								lihtml += '<li class="show_img_li">' +
									'<img src=' + img_arr5[i] + ' >' +
									'<p onclick="delimg(' + i + ',5,this)">删除</p>' +
									'</li>'
							}
							break;
						default:
							break;
					}
					$('#' + dom).html(lihtml);
				}

				function initdata() {
					loading()
					$.get(server.querygoodsdetail, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var data = res.goods_info

								$("input[name=status][value=" + data.data.status + "]").attr("checked", true);
								$("input[name=type][value=" + data.data.type + "]").attr("checked", true);
								$("input[name=level][value=" + data.data.level + "]").attr("checked", true);
								data.data.goods_image_url ? createli(data.data.goods_image_url, 'zhutu', '1') :
									''
								data.data.goods_gallery_urls ? createli(data.data.goods_gallery_urls, 'lunbo',
									'2') : ''
								data.data.video_url ? createli(data.data.video_url, 'video_url', '3') : ''
								data.data.video_cover ? createli(data.data.video_cover, 'video_cover', '4') : ''
								data.data.examples_img_url ? createli(data.data.examples_img_url, 'shili', '5') :
									''
								_data.spuid = data.data.spuid;
								$(".on_off input[value=" + data.data.status + "]").attr("checked", true)
								if (data.data.client) {
									var client_arr = data.data.client.split(',')
									for (var i = 0; i < client_arr.length; i++) {
										$(".icon_type input[value=" + client_arr[i] + "]").attr("checked", true)
									}
								}
								if (data.data.sub_service) {
									for (var i = 0; i < data.data.sub_service.length; i++) {
										goods_arr.push({
											skuid: data.data.sub_service[i].skuid,
											skuname: data.data.sub_service[i].skuname
										})
									}
									show_goods_arr(goods_arr)
								}
								if (data.data.type.toString() == '1') {
									$(".service_goods").show();
								} else {
									$(".service_goods").hide();
								}
								form.val("test_detail", data.data);
								form.render();
								edit.setContent(data.data.content)
								closeloading()
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
					closeloading()
				}
				/**
				 * 
				 * @param {Object} type 0 add , 1  edit
				 * @param {Object} edit
				 */
				window.productdetail = function(spuid, type) {
					loading()
					$.get(server.op_queryproductdetail, {
						spuid: spuid
					}, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var data = res.product
								data.data.goods_img ? createli(data.data.goods_img, 'zhutu', '1') : ''
								data.data.gallery_url ? createli(data.data.gallery_url, 'lunbo', '2') : ''
								data.data.video_url ? createli(data.data.video_url, 'video_url', '3') : ''
								data.data.video_cover ? createli(data.data.video_cover, 'video_cover', '4') :
									''
								data.data.examples_img_url ? createli(data.data.examples_img_url, 'shili',
									'5') : ''
								data.data.spuname ? $("input[name=skuname]").val(data.data.spuname) : ""
								data.data.specname ? $("input[name=specname]").val(data.data.specname) : ""
								data.data.specparam ? $("input[name=specparam]").val(data.data.specparam) :
									""
								data.data.price ? $("input[name=price]").val(data.data.price) : ""
								data.data.score_scale ? $("input[name=score_scale]").val(data.data
									.score_scale) : ""


								data.data.brandid ? $("input[name=brand_id]").val(data.data.brandid) : ""
								data.data.brandname ? $("input[name=brand_name]").val(data.data.brandname) :
									""

								data.data.intro ? $("textarea[name=intro]").val(data.data.intro) : ""
								data.data.support ? $("textarea[name=support]").val(data.data.support) : ""
								data.data.instructions ? $("textarea[name=instructions]").val(data.data
									.instructions) : ""


								data.data.price_member ? $("input[name=price_member]").val(data.data
									.price_member) : ""
								data.data.price_waybill ? $("input[name=price_waybill]").val(data.data
									.price_waybill) : ""
								data.data.notes ? $("input[name=notes]").val(data.data.notes) : ""

								edit.setContent(data.data.content)

							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
					closeloading()
				}

				$(".spec_add").bind("click", function(e) {
					var current = e.currentTarget //当前节点
					var current_parent = e.currentTarget.parentNode //当前父节点
					var deepList = current_parent.cloneNode(true); //拷贝父节点 

					current_parent.parentNode.insertBefore(deepList, current_parent) // 插入到 当前父节点 上面
					current_parent.previousElementSibling.removeChild($(".spec_add")[0]) // 

					var nodes_list = e.currentTarget.parentNode.parentNode.childNodes
				})

				$(".spec_del").bind("click", function(e) {
					var current = e.currentTarget //当前节点
					var current_parent = e.currentTarget.parentNode //当前父节点
					current_parent.parentNode.remove(current_parent)
				})

				function get_spec(nodes_list, _data) {
					var obj = {}
					str = 'obj.skuid=' + _data.skuid
					for (var i = 0; i < nodes_list.length; i++) {
						var node = nodes_list[i]
						var spec_k = $(node).find('input[name=spec_k]').val(),
							spec_v = $(node).find('input[name=spec_v]').val();
						if (spec_k) {
							str += ",obj." + spec_k + "='" + spec_v + "'"
							eval(str);
						}
					}
					return JSON.stringify(obj)
				}

				$(document).on("click", ".del_tr", function(e) {

					var index = $(this).attr("index")
					goods_arr.splice(index - 1, 1)
					console.log(goods_arr)
					$(this).parent().parent().remove()
					$(this).parent().parent().remove()
				})

				function initmodule() {
					var modulelist = [{
							id: 'on_off',
							name: '商品状态',
							input_btn: '2',
							inputlist: [{
									name: '停用',
									status: '0'
								},
								{
									name: '启用',
									status: '1'
								}
							]
						},
						{
							id: 'goods_type',
							name: '商品类型',
							input_btn: '2',
							inputlist: [{
									name: '商品',
									status: '0'
								},
								{
									name: '服务',
									status: '1'
								},
								{
									name: '物料',
									status: '2'
								}
							]
						},
						{
							id: 'icon_type',
							name: '客户端',
							input_btn: '3',
							inputlist: [{
									name: 'Android',
									status: '0'
								},
								{
									name: 'IOS',
									status: '1'
								},
								{
									name: '小程序',
									status: '2'
								}
							]
						},
						{
							id: 'fq_status',
							name: '分期',
							input_btn: '2',
							inputlist: [{
									name: '不分期',
									status: '0'
								},
								{
									name: '12期',
									status: '12'
								},
								{
									name: '9期',
									status: '9'
								},
								{
									name: '6期',
									status: '6'
								},
								{
									name: '3期',
									status: '3'
								}

							]
						},
						{
							id: 'recommend',
							name: '是否推荐',
							input_btn: '2',
							inputlist: [{
									name: '否',
									status: '0'
								},
								{
									name: '是',
									status: '1'
								}
							]
						},
						{
							id: 'cart',
							name: '是否加入购物车',
							input_btn: '2',
							inputlist: [{
									name: '否',
									status: '0'
								},
								{
									name: '是',
									status: '1'
								}
							]
						},
						{
							id: 'skuname',
							name: '商品名称',
							input_btn: '1',
							verify: '1'
						},
						{
							id: 'title',
							name: '商品简称',
							input_btn: '1',
						},
						{
							id: 'low_quantity',
							name: '最低购买数量',
							input_btn: '1',
						},
						{
							id: 'spuname',
							name: '产品名称',
							input_btn: '1',
						},
						{
							id: 'spuid',
							name: '产品编号',
							input_btn: '1',
							openspuid: '1'
						},
						{
							id: 'direct_fee',
							name: '直接佣金',
							input_btn: '1',
						},
						{
							id: 'indirect_fee',
							name: '间推佣金',
							input_btn: '1',
						},
						{
							id: 'team_fee',
							name: '团队佣金',
							input_btn: '1',
						},
						{
							id: 'copartner_fee',
							name: '合伙人佣金',
							input_btn: '1',
						},
						{
							id: 'area_fee',
							name: '区域店铺佣金',
							input_btn: '1',
						},
						{
							id: 'city_fee',
							name: '城市店铺佣金',
							input_btn: '1',
						},
						{
							id: 'specname',
							name: '规格名称',
							input_btn: '1',
						},
						{
							id: 'specparam',
							name: '规格参数',
							input_btn: '1',
						},
						{
							id: 'measure_unit',
							name: '计量单位',
							input_btn: '1',
						},
						{
							id: 'price',
							name: '原价',
							input_btn: '1',
						},
						{
							id: 'price_member',
							name: '购买会员价',
							input_btn: '1',
						},
						{
							id: 'discount',
							name: '折扣',
							input_btn: '1',
						},
						{
							id: 'score',
							name: '积分抵扣',
							input_btn: '1',
						},
						{
							id: 'level',
							name: '专属等级',
							input_btn: '6',
						},
						{
							id: 'grade',
							name: '赠送等级',
							input_btn: '6',
						},
						{
							id: 'grade_month',
							name: '赠送月份',
							input_btn: '1',
						},
						{
							id: 'stock',
							name: '当前库存',
							input_btn: '1',
						},
						{
							id: 'sales',
							name: '当前销量',
							input_btn: '1',
						},
						{
							id: 'price_waybill',
							name: '商品运费',
							input_btn: '1',
						},
						{
							id: 'instructions',
							name: '发货说明',
							input_btn: '4',
						},
						{
							id: 'intro',
							name: '商品简介',
							input_btn: '4',
						},
						{
							id: 'content',
							name: '商品介绍',
							input_btn: '5',
						},
						{
							id: 'support',
							name: '店铺信息',
							input_btn: '4',
						},
						{
							id: 'shili',
							name: '商品示例图',
							input_btn: '7',
							data: '5'
						},
						{
							id: 'zhutu',
							name: '商品主图',
							input_btn: '7',
							data: '1'
						},
						{
							id: 'lunbo',
							name: '商品轮播图',
							input_btn: '7',
							data: '2'
						},
						{
							id: 'video',
							name: '视频',
							input_btn: '7',
							data: '3'
						},
						{
							id: 'video_cover',
							name: '商品视频封面',
							input_btn: '7',
							data: '4'
						}
					];
					// 1 输入框  2 点选按钮  3 多选按钮  4 文本输入框  5文本编辑器  6下拉框  7 上传图片
					console.log(modulelist)

					var getTpl = input_list.innerHTML,
						view = document.getElementById('input_li');
					laytpl(getTpl).render(modulelist, function(html) {
						view.innerHTML = html;
					});
				}




			});
		</script>
	</body>
</html>